package commons;


import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;


public class AutoRefresh extends Thread {

	private Manager manager;
	private boolean running=true;

	public AutoRefresh(Manager proc){
		this.manager=proc;
	}

	public void run(){
			ArrayList<User> usList = manager.getUserList().getUserArrayList();
			Object[] table=usList.toArray();
			if(table.length!=0){
				for(int i=0;i<table.length;i++){
					if(!isActive((User)table[i])){
						System.out.println("remove "+((User)table[i]).getName());
						manager.delUser((User)table[i]);
				}
			}
		}
	}

	public boolean isActive(User user){
		if(user.getTimeStamp()<1800000){
			return true;
		}
		else{
			return false;
		}
	}

	public void kill(){
		this.running=false;
	}
}
